import 'package:flutter/material.dart';

class WalletDetailsPage extends StatelessWidget {
  final List<String> _titles = ['钱包名称', '导出助记词', '导出私钥', 'EOS管理'];
  final String _userName = 'jack';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('钱包详情'),
        leading: IconButton(
            icon: Icon(Icons.arrow_back, size: 28),
            onPressed: () {
              Navigator.of(context).pop();
            }),
      ),
      body: Container(
        color: Color.fromRGBO(221, 221, 221, 1),
        margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
        child: ListView.separated(
          itemCount: _titles.length + 1,
          physics: NeverScrollableScrollPhysics(),
          itemBuilder: (ctx, index) {
            if (index == 0) {
              return _headerWidget();
            }
            return _bodyCell(index, _titles[index - 1]);
          },
          separatorBuilder: (ctx, index) {
            return Divider(
              color: Color.fromRGBO(221, 221, 221, 1),
              height: 1,
            );
          },
        ),
      ),
    );
  }

  Widget _headerWidget() {
    return Container(
      height: 30,
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.only(left: 15),
      color: Color.fromRGBO(221, 221, 221, 1),
      child: Text(
        '钱包信息',
        style: TextStyle(color: Color.fromRGBO(144, 144, 144, 1), fontSize: 12),
      ),
    );
  }

  Widget _bodyCell(int index, String title) {
    Widget trailing;

    if (index == 1) {
      trailing = Text(_userName, style: TextStyle(fontSize: 16));
    } else {
      trailing = IconButton(
        alignment: Alignment.centerRight,
        iconSize: 14,
        icon: Icon(Icons.arrow_forward_ios),
        onPressed: () {
          print('点击了:$title');
        },
      );
    }

    return Container(
      alignment: Alignment.centerLeft,
      color: Colors.white,
      child: ListTile(
        leading: Text(
          title,
          style: TextStyle(fontSize: 16),
        ),
        trailing: trailing,
      ),
    );
  }
}
